@echo off

rem cmake -B/path/to/my/build/folder -H/path/to/my/source/folder

cls

rem -----------------------------------------------------------------------------

set MODE=Debug
set ADDRESSMODEL=32

rem -----------------------------------------------------------------------------

if "%NAME_PRODUCT%"     == ""   for %%a in (.) do set NAME_PRODUCT=%%~na
if "%SOURCE_DIRECTORY%" == ""   set SOURCE_DIRECTORY=%~dp0
if "%GENERATOR%"        == ""   set GENERATOR=Visual Studio 11
if "%TOOLSET%"          == ""   set TOOLSET=v120_CTP_Nov2012
if "%MODE%"             == ""   set MODE=Debug
if "%ADDRESSMODEL%"     == ""   set ADDRESSMODEL=32
if "%ADDRESSMODEL%"     == "64" set SUFFIX= Win64
if "%BUILDDIR%"         == ""   set BUILDDIR=%MODE%%ADDRESSMODEL%

echo PROJECT NAME ......... %NAME_PRODUCT%
echo SOURCE DIRECTORY ..... %SOURCE_DIRECTORY%
echo IDE .................. %GENERATOR%%SUFFIX%
echo TOOLSET .............. %TOOLSET%
echo BUILD TYPE ........... %MODE%
echo ADDRESS MODEL ........ %ADDRESSMODEL%

rem -----------------------------------------------------------------------------

if not exist build ( mkdir build )
cd build

set BUILDDIR=%MODE%%ADDRESSMODEL%
if exist %BUILDDIR% ( rmdir /s /q %BUILDDIR% )
mkdir %BUILDDIR%
cd %BUILDDIR%

cmake  -G "%GENERATOR%%SUFFIX%" ^
       -T "%TOOLSET%" ^
       -DCMAKE_BUILD_TYPE=%MODE% ^
        %SOURCE_DIRECTORY%

rem -----------------------------------------------------------------------------

echo [ building ] ...

cmake --build . --config %MODE%
exit /b

       

